package cn.ekgc.bmdsad.day1;

public class MyLinkedList {
    private int count;
    private MyNode head;
    private MyNode tail;

    class MyNode{

        public int data;
        public MyNode next;
    }
    public void add(int i) {
        count++;
        MyNode node = new MyNode();
        node.data=i;
        if(head == null){
            head = node;
        }else{
            tail.next =node;
        }
        tail = node;

    }

    public int size() {

        return count;
    }
    public int get(int i) {
        MyNode p = head;
        for (int j = 0; j < i; j++) {
            p = p.next;
        }
        return p.data;
    }
}
